import 'package:flutter_duqin/models/recommend_interface.dart';
import 'package:flutter_duqin/models/user_model.dart';

/// 歌曲列表模型
class SongList {
  final List<SongItem> list;

  SongList(this.list);

  factory SongList.fromJson(List<dynamic> list) {
    return SongList(
      list.map((item) => SongItem.fromJson(item)).toList(),
    );
  }
}

/// 歌曲模型
class SongItem implements RecommendInterface {
  final int id;
  final String cnName;
  final int commentCount;
  final String coverPictureUrl;
  final String enName;
  final int readCount;
  final String songUrl;
  final int thumbUpCount;
  final int userId;
  final UserItem user;

  SongItem({
    required this.id,
    required this.cnName,
    required this.commentCount,
    required this.coverPictureUrl,
    required this.enName,
    required this.readCount,
    required this.songUrl,
    required this.thumbUpCount,
    required this.userId,
    required this.user,
  });

  factory SongItem.fromJson(dynamic item) {
    return SongItem(
        id: item['id'],
        cnName: item['cnName'],
        commentCount: item['commentCount'],
        coverPictureUrl: item['coverPictureUrl'],
        enName: item['enName'],
        readCount: item['readCount'],
        songUrl: item['songUrl'],
        thumbUpCount: item['thumbUpCount'],
        userId: item['userId'],
        user: UserItem.fromJson(item['user']));
  }
}
